const Logger = require('node-json-logger');

const LOG_LEVELS = {
  'trace': 'trace',
  'debug': 'debug',
  'info': 'info',
  'warn': 'warn',
  'error': 'error',
  'fatal': 'fatal'
};

function getLogger (logLevel) {
  switch (logLevel ? logLevel.toLowerCase() : 'default') {
    case 'trace':
      return new Logger({ 'level': LOG_LEVELS.trace });
    case 'debug':
      return new Logger({ 'level': LOG_LEVELS.debug });
    case 'info':
      return new Logger({ 'level': LOG_LEVELS.info });
    case 'warn':
    case 'warning':
      return new Logger({ 'level': LOG_LEVELS.warn });
    case 'error':
      return new Logger({ 'level': LOG_LEVELS.error });
    case 'fatal':
      return new Logger({ 'level': LOG_LEVELS.fatal });
    default:
      return new Logger({ 'level': LOG_LEVELS.error });
  }
}

exports.LOG_LEVEL = LOG_LEVELS;
exports.getLogger = getLogger;
